🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / core / model / src / commonMain / kotlin / org / meshtastic / core / model / util / DateTimeUtils.kt
Displaying Raw • Download
core/model/src/commonMain/kotlin/org/meshtastic/core/model/util/DateTimeUtils.kt 4e15ef1c7f68f8c683fe8b7ff741a5167e154d2e (4e15ef1c) Text, 2.32 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.model.util
Tff7b72import T7ee787org.meshtastic.core.model.util.TimeConstants.HOURS_PER_DAY
Tff7b72import T7ee787kotlin.time.Duration.Companion.milliseconds
Tff7b72import T7ee787kotlin.time.Duration.Companion.seconds
T8b949e/**
* Returns a short string representing the time if it's within the last 24 hours, otherwise returns a combined short
* date/time string.
*
* @param time The time in milliseconds
* @return Formatted date/time string
*/
Tff7b72expect Tff7b72fun Td2a8ffgetShortDateTimeTb4b4b4(Te6edf3timeTb4b4b4: Tffa657LongTb4b4b4)Tb4b4b4: Tffa657String
T8b949e/**
* Formats a duration in seconds as a human-readable uptime string (e.g., "1d 2h 3m 4s").
*
* @param seconds The duration in seconds.
* @return A formatted uptime string.
*/
Tff7b72fun Td2a8ffformatUptimeTb4b4b4(Te6edf3secondsTb4b4b4: Tffa657IntTb4b4b4)Tb4b4b4: Tffa657String Tb4b4b4{
Tff7b72val Te6edf3secs Tff7b72= Te6edf3secondsTb4b4b4.Te6edf3toLongTb4b4b4(Tb4b4b4)
Tff7b72if Tb4b4b4(Te6edf3secs Tff7b72=Tff7b72= T79c0ff0LTb4b4b4) Tff7b72return Ta5d6ff"Ta5d6ff0sTa5d6ff"
Tff7b72return Te6edf3secsTb4b4b4.Te6edf3secondsTb4b4b4.Te6edf3toComponents Tb4b4b4{ Te6edf3daysTb4b4b4, Te6edf3hoursTb4b4b4, Te6edf3minutesTb4b4b4, Te6edf3sTb4b4b4, Te6edf3_ Tff7b72-Tff7b72>
Te6edf3listOfNotNullTb4b4b4(
Ta5d6ff"Tffd700${Te6edf3daysTffd700}Ta5d6ffdTa5d6ff"Tb4b4b4.Te6edf3takeIf Tb4b4b4{ Te6edf3days Tff7b72> T79c0ff0 Tb4b4b4}Tb4b4b4,
Ta5d6ff"Tffd700${Te6edf3hoursTffd700}Ta5d6ffhTa5d6ff"Tb4b4b4.Te6edf3takeIf Tb4b4b4{ Te6edf3hours Tff7b72> T79c0ff0 Tb4b4b4}Tb4b4b4,
Ta5d6ff"Tffd700${Te6edf3minutesTffd700}Ta5d6ffmTa5d6ff"Tb4b4b4.Te6edf3takeIf Tb4b4b4{ Te6edf3minutes Tff7b72> T79c0ff0 Tb4b4b4}Tb4b4b4,
Ta5d6ff"Tffd700${Te6edf3sTffd700}Ta5d6ffsTa5d6ff"Tb4b4b4.Te6edf3takeIf Tb4b4b4{ Te6edf3s Tff7b72> T79c0ff0 Tb4b4b4}Tb4b4b4,
Tb4b4b4)
Tb4b4b4.Te6edf3joinToStringTb4b4b4(Ta5d6ff"Ta5d6ff Ta5d6ff"Tb4b4b4)
Tb4b4b4}
Tb4b4b4}
T8b949e/**
* Calculates the remaining mute time in days and hours.
*
* @param remainingMillis The remaining time in milliseconds
* @return Pair of (days, hours), where days is Int and hours is Double
*/
Tff7b72fun Td2a8ffformatMuteRemainingTimeTb4b4b4(Te6edf3remainingMillisTb4b4b4: Tffa657LongTb4b4b4)Tb4b4b4: Te6edf3PairTff7b72<Tffa657IntTb4b4b4, Tffa657DoubleTff7b72> Tb4b4b4{
Tff7b72val Te6edf3duration Tff7b72= Te6edf3remainingMillisTb4b4b4.Te6edf3milliseconds
Tff7b72if Tb4b4b4(Te6edf3duration Tff7b72<Tff7b72= Te6edf3kotlinTb4b4b4.Te6edf3timeTb4b4b4.Te6edf3DurationTb4b4b4.Te6edf3ZEROTb4b4b4) Tff7b72return T79c0ff0 Te6edf3to T79c0ff0.0
Tff7b72val Te6edf3totalHours Tff7b72= Te6edf3durationTb4b4b4.Te6edf3toDoubleTb4b4b4(Te6edf3kotlinTb4b4b4.Te6edf3timeTb4b4b4.Te6edf3DurationUnitTb4b4b4.Te6edf3HOURSTb4b4b4)
Tff7b72return Tb4b4b4(Te6edf3totalHours Tff7b72/ Te6edf3HOURS_PER_DAYTb4b4b4)Tb4b4b4.Te6edf3toIntTb4b4b4(Tb4b4b4) Te6edf3to Tb4b4b4(Te6edf3totalHours Tff7b72% Te6edf3HOURS_PER_DAYTb4b4b4)
Tb4b4b4}
Served by rngit 1.5.0 - Generated in 0.04s